//
//  UIBarButtonItem+SZ.m
//  Weibo
//
//  Created by Zahi on 2017/7/23.
//  Copyright © 2017年 Zahi. All rights reserved.
//

#import "UIBarButtonItem+SZ.h"

@implementation UIBarButtonItem (SZ)


+ (UIBarButtonItem *)barButtonItemWithTitle:(NSString *)title image:(NSString *)imgName target:(id)target action:(SEL)action
{
    
    UIButton *btn = [UIButton new];
    
    if (imgName != nil) {
        [btn setImage:[UIImage imageNamed:imgName] forState:UIControlStateNormal];
    }
    
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    [btn setTitle:title forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
    [btn setTitleColor:[UIColor orangeColor] forState:UIControlStateHighlighted];
    
    btn.titleLabel.font = [UIFont systemFontOfSize:15];
    
    [btn sizeToFit];
    
    UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    
    
    return barButtonItem;
    
    
    
}

@end
